package banwood.com.xiongfasy;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;


import banwood.com.xiongfasy.activity.HomeActivity;
import banwood.com.xiongfasy.activity.MyApplication;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class MainActivity extends Activity {

    @BindView(R.id.username)
    EditText username;
    @BindView(R.id.username_delete)
    ImageView usernameDelete;
    @BindView(R.id.password)
    EditText password;
    @BindView(R.id.password_delete)
    ImageView passwordDelete;
    @BindView(R.id.login_bt)
    Button loginBt;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        ButterKnife.bind(this);
    }


    @OnClick({R.id.username_delete,R.id.password_delete,R.id.login_bt})
    public void onclick(View view){
        switch (view.getId()){
            case R.id.username_delete:
                username.setText("");
                break;
            case R.id.password_delete:
                password.setText("");
                break;
            case R.id.login_bt:
                if(!TextUtils.isEmpty(username.getText().toString().trim())){
                    if(!TextUtils.isEmpty(password.getText().toString().trim())){
                        Intent intent = new Intent(MainActivity.this, HomeActivity.class);
                        startActivity(intent);
                        MyApplication.setUserName(username.getText().toString().trim());
                    }else {
                        Toast.makeText(MainActivity.this,"请输入密码",Toast.LENGTH_SHORT).show();
                    }
                }else {
                    Toast.makeText(MainActivity.this,"请输入操作员号",Toast.LENGTH_SHORT).show();
                }

                break;
        }

    }





}
